package com.test.mchelepesa.bean_rice.user_info_rice;

import com.test.mchelepesa.util_rice.StringUtil_rice;
import com.google.gson.Gson;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.LinkedHashMap;

public class LoanLimitInfo_rice {

    private static class Inner {
        private static LoanLimitInfo_rice instance = new LoanLimitInfo_rice();
    }

    private LoanLimitInfo_rice(){}

    public static LoanLimitInfo_rice getInstance(){
        return Inner.instance;
    }

    private String newUserFlag;
    private String currency;
    private ArrayList<LinkedHashMap<String,String>> limit;

    public static void parse(JSONObject objJson){
        Inner.instance = new Gson().fromJson(objJson.toString(), LoanLimitInfo_rice.class);
    }

    public boolean isNewUSer() {
        return StringUtil_rice.getSafeString(newUserFlag).equalsIgnoreCase("YES");
    }

    public String getLimitAmount(){
        if (limit == null||limit.size()==0) return "";
        return limit.get(0).get("amount");
    }

    public String getLimitIncreasedAmount1(){
        if (limit == null||limit.size()==0) return "";
        return limit.get(0).get("increasedAmount1");
    }

    public String getLimitIncreasedAmount2(){
        if (limit == null||limit.size()==0) return "";
        return limit.get(0).get("increasedAmount2");
    }

    public String getCurrency() {
        return StringUtil_rice.getSafeString(currency);
    }
}
